<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<script>
description('Checks incomplete datetime formats are rejected.');

var input = document.createElement('input');
input.type = 'week';
document.body.appendChild(input);

function setDateTimeFormat(pattern) {
    var value = input.value;
    getElementByPseudoId(internals.shadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern);
    input.value = ''; // Updates the element for new format
    input.value = value;
}

input.value = '1999-W09';

debug('Valid format');
setDateTimeFormat("'Week'ww yyyy");
shouldBeEqualToString('getUserAgentShadowTextContent(input)', 'Week09 1999');

debug("Invalid format, fallback to yyyy-'W'ww");
setDateTimeFormat('ww');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-W09');
setDateTimeFormat('yyyy');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-W09');

</script>
</body>
</html>
